import { createApp, defineAsyncComponent } from 'vue';
import App from './App.vue';
const app = createApp(App);
import router from './router';
import { i18n } from '@/i18n/index';
import { directive } from '@/directive/index';
import other from '@/utils/other';
import ElementPlus from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import '@/theme/index.scss';
import VueGridLayout from 'vue-grid-layout';
import global from './global';
import func from './plugins/func';
import installTable from './components/zh-table/install';
import store from '@/store/pinia';
import JsonViewer from 'vue3-json-viewer';
import formCreate from '@form-create/element-ui';
import '@/components/lib/formComponents';
import JsonEditorVue from 'json-editor-vue3';
import * as elIcons from '@element-plus/icons-vue';
import '@/theme/common/common.scss';
// 全局注册组件
const requireModules = import.meta.glob('./components/*/*.vue');
for (const path in requireModules) {
	const name = path.substring(13).replace(/\/index.vue/, '');
	const modulesContent: any = requireModules[path];
	app.component(name, defineAsyncComponent(modulesContent));
}
directive(app);
other.elSvg(app);

// 统一注册el图标
for (let icon in elIcons) {
	app.component(`ElIcon${icon}`, elIcons[icon])
}

app
	.use(store)
	.use(router)
	.use(global)
	.use(installTable)
	.use(ElementPlus,{locale: zhCn,size:'default'})
	.use(formCreate)
	.use(i18n)
	.use(VueGridLayout)
	.use(JsonViewer)
	// .use(JsonEditorVue)
	.mount('#app');
app.directive('func', func);
